"use client";

import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import type * as React from "react";

import { buttonVariants } from "@/components/plate/ui/button";
import { cn } from "@/lib/utils";

function AlertDialog({
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Root&gt;) {
  return &lt;AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} /&gt;;
}

function AlertDialogTrigger({
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Trigger&gt;) {
  return (
    &lt;AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} /&gt;
  );
}

function AlertDialogPortal({
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Portal&gt;) {
  return (
    &lt;AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} /&gt;
  );
}

function AlertDialogOverlay({
  className,
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Overlay&gt;) {
  return (
    &lt;AlertDialogPrimitive.Overlay
      data-slot="alert-dialog-overlay"
      className={cn(
        "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
        className,
      )}
      {...props}
    /&gt;
  );
}

function AlertDialogContent({
  className,
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Content&gt;) {
  return (
    &lt;AlertDialogPortal&gt;
      &lt;AlertDialogOverlay /&gt;
      &lt;AlertDialogPrimitive.Content
        data-slot="alert-dialog-content"
        className={cn(
          "fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-lg",
          className,
        )}
        {...props}
      /&gt;
    &lt;/AlertDialogPortal&gt;
  );
}

function AlertDialogHeader({
  className,
  ...props
}: React.ComponentProps&lt;"div"&gt;) {
  return (
    <div data-slot="alert-dialog-header" />
  );
}

function AlertDialogFooter({
  className,
  ...props
}: React.ComponentProps&lt;"div"&gt;) {
  return (
    <div data-slot="alert-dialog-footer" />
  );
}

function AlertDialogTitle({
  className,
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Title&gt;) {
  return (
    &lt;AlertDialogPrimitive.Title
      data-slot="alert-dialog-title"
      className={cn("text-lg font-semibold", className)}
      {...props}
    /&gt;
  );
}

function AlertDialogDescription({
  className,
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Description&gt;) {
  return (
    &lt;AlertDialogPrimitive.Description
      data-slot="alert-dialog-description"
      className={cn("text-sm text-muted-foreground", className)}
      {...props}
    /&gt;
  );
}

function AlertDialogAction({
  className,
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Action&gt;) {
  return (
    &lt;AlertDialogPrimitive.Action
      className={cn(buttonVariants(), className)}
      {...props}
    /&gt;
  );
}

function AlertDialogCancel({
  className,
  ...props
}: React.ComponentProps&lt;typeof AlertDialogPrimitive.Cancel&gt;) {
  return (
    &lt;AlertDialogPrimitive.Cancel
      className={cn(buttonVariants({ variant: "outline" }), className)}
      {...props}
    /&gt;
  );
}

export {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogOverlay,
  AlertDialogPortal,
  AlertDialogTitle,
  AlertDialogTrigger,
};
